import { Component, OnInit } from '@angular/core';
import { Input } from '@angular/core';
import { Schedule, DEGREE, STATUS } from '../model/schedule';

@Component({
  selector: 'app-schedule',
  templateUrl: './schedule.component.html',
  styleUrls: ['./schedule.component.css']
})
export class ScheduleComponent implements OnInit {

  @Input() schedule: Schedule;

  degreeText = {
    [DEGREE.SERIOURS_URGENT]: '【重】【急】',
    [DEGREE.SERIOURS_NOT_URGENT]: '【重】',
    [DEGREE.NOT_SERIOURS_NOT_URGENT]: '',
    [DEGREE.NOT_SERIOURS_URGENT]: '【急】'
  }
  statusText = {
    [STATUS.ARCHIVE]: '【完】',
    [STATUS.PROCESSING]: '【未完】'
  }
  public isShowAlarm: boolean;
  constructor() {
   }

  ngOnInit() {
    if (this.schedule.endTime && !(this.schedule.endTime instanceof Date)) {
      this.schedule.endTime = new Date(this.schedule.endTime);
      console.log(this.schedule.endTime.valueOf() - Date.now())
    }
    if (this.schedule.endTime && (this.schedule.endTime.valueOf() - Date.now() < 24 * 60 * 60 * 1000)) {
      this.isShowAlarm = true;
    }
  }

}
